﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:fn="http://www.w3.org/2005/xpath-functions">
<!--
程序名:权限初始化数据生成工具
版本号    修改者    修改时间    修改描述
1.0       liuleyi   20150609    创建此程序
-->
	<xsl:output method="text" indent="no" encoding="utf-8" byte-order-mark="no"/>  
	<xsl:template match="/">

<xsl:result-document encoding="utf-8" method="text" href="./generate/sql/InitData/init_Permission.sql">
/*
权限位初始化数据脚本
*/
<xsl:for-each select="Systems">
<xsl:for-each select="Lccode">
<xsl:variable name="LcCode" select="@code"/>
DELETE t_mc_permission where lccode='<xsl:value-of select="$LcCode"/>';
DELETE t_mc_permission_func where lccode='<xsl:value-of select="$LcCode"/>';<xsl:for-each select="System"><xsl:variable name="SystemType" select="@type"/><xsl:for-each select="Module"><xsl:variable name="ModuleCode" select="@code"/>
<xsl:for-each select="Permission">
<xsl:variable name="Index" select="@index"/>
<xsl:variable name="Desc" select="@desc"/>
<xsl:variable name="ButtonCtl" select="@isButtonCtl"/>
INSERT INTO t_mc_permission(lccode,systemtype,appmodeltype,permissionno,functionno,permissiondesc,IsButtonCtl,updateoperid,updatedate,updatetime) VALUES ('<xsl:value-of select="$LcCode"/>','<xsl:value-of select="$SystemType"/>','<xsl:value-of select="$ModuleCode"/>',<xsl:value-of select="$Index"/>,'','<xsl:value-of select="$Desc"/>','<xsl:value-of select="$ButtonCtl"/>','SSS',Pkg_Tool.Getoperdate(),Pkg_Tool.Getopertime());
<xsl:for-each select="Func">
INSERT INTO t_mc_permission_func(lccode,systemtype,appmodeltype,permissionno,functionno,updateoperid,updatedate,updatetime) VALUES ('<xsl:value-of select="$LcCode"/>','<xsl:value-of select="$SystemType"/>','<xsl:value-of select="$ModuleCode"/>',<xsl:value-of select="$Index"/>,'<xsl:value-of select="@no"/>','SSS',Pkg_Tool.Getoperdate(),Pkg_Tool.Getopertime());
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
COMMIT;
</xsl:result-document>
	</xsl:template>  
</xsl:stylesheet>